<template>
    <div>
        <h1>权益录入</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">权益名称</td>
                    <td><input type="text" v-model="info.Name"></td>
                </tr>
                <tr>
                    <td align="right">权益状态</td>
                    <td><input type="radio" name="sta" v-model="info.QYZT" :value="true">启用
                        <input type="radio" name="sta" v-model="info.QYZT" :value="false">禁用
                    </td>
                </tr>
                <tr>
                    <td align="right"></td>
                    <td><input type="button" value="录入" @click="ok"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref, reactive,onMounted} from 'vue'
import axios from 'axios';
import { useRouter,useRoute } from 'vue-router';
const router=useRouter();
const route=useRoute();
let info:any=reactive({
  Name: '',
  QYZT: '',
})
const ok=()=>{
    if(info.Name=="")
{
        alert("权益名称不能为空");
        return;
};
    axios({
        url:'/api/QY/Add',
        method:'post',
        data:info
    })
    .then((res)=>{
        console.log(res);
        if(res.data==-1)
    {
        alert("权益名称重复");
        return;
    }
    if(res.data>0)
    {
        alert("录入成功");
        router.push('/qyshow')
        return;
    }
    else
    {
        alert("录入失败");
        return;
    }
        
    })
}
</script>

<style scoped>

</style>